import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Main20250322 {
}

class Solution {
    public int[] rowAndMaximumOnes(int[][] mat) {
        int[] res = new int[2];
        for (int i = 0; i < mat.length; i++) {
            int[] row = mat[i];
            int sum = Arrays.stream(row).sum();
            if (sum > res[1]) {
                res[0] = i;
                res[1] = sum;
            }
        }
        return res;
    }

    class Solution {
        public String simplifyPath(String path) {
            //"/.../a/../b/c/../d/./"
            path += "/";
            List<String> fileNames = new ArrayList<>();
            int i = 0;
            while (i < path.length()) {
                char ch = path.charAt(i);
                if (ch == '/') {
                    //判断后面几个/
                    while (i < path.length() && path.charAt(i) == '/') {
                        i++;
                    }
                } else if (ch == '.') {
                    //判断是不是/./
                    if (i + 1 < path.length() && path.charAt(i + 1) == '/' && path.charAt(i - 1) == '/') {
                        i = i + 2;
                    } else if (i + 2 < path.length() && path.charAt(i + 1) == '.' && path.charAt(i + 2) == '/' && path.charAt(i - 1) == '/') {
                        //判断是不是/../
                        if (fileNames.size() != 0) {
                            fileNames.remove(fileNames.size() - 1);
                        }
                        i = i + 3;
                    } else {
                        //加入文件名
                        StringBuilder stringBuilder = new StringBuilder();
                        while (i < path.length() && path.charAt(i) != '/') {
                            stringBuilder.append(path.charAt(i));
                            i++;
                        }
                        fileNames.add(stringBuilder.toString());
                    }
                } else {
                    //加入文件名
                    StringBuilder stringBuilder = new StringBuilder();
                    while (i < path.length() && path.charAt(i) != '/') {
                        stringBuilder.append(path.charAt(i));
                        i++;
                    }
                    fileNames.add(stringBuilder.toString());
                }
            }
            return "/" + String.join("/", fileNames);
        }
    }
}